package com.warren.system.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.warren.handler.BusinessException;
import com.warren.response.Result;
import com.warren.system.dto.LoginRequest;
import com.warren.system.entity.Role;
import com.warren.system.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.warren.system.vo.UserEditVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 用户表 服务类
 * </p>
 *
 * @author warren
 * @since 2021-03-21
 */
public interface UserService extends IService<User> {

    IPage<User> findUserPage(Page<User> page, QueryWrapper<User> wrapper);

    /**
     * 添加用户
     * @param user
     */
    void addUser(User user);

    /**
     * 导出用户excel
     * @param response
     * @param users
     * @throws IOException
     */
    void exportUserExcel(HttpServletResponse response, List<User> users) throws IOException;

    /**
     * 获取编辑用户信息
     * @param id
     * @return
     */
    UserEditVO edit(long id)throws BusinessException;

    /**
     * 更新编辑用户
     * @param id
     * @param userVO
     * @throws BusinessException
     */
    void updateUser(long id,UserEditVO userVO)throws BusinessException;

    /**
     * 通过id删除用户
     * @param id
     * @throws BusinessException
     */
    void deleteById(Long id) throws  BusinessException;

    /**
     * 更新状态
     * @param id
     * @param status
     * @throws BusinessException
     */
    void updateStatus(Long id,Boolean status) throws BusinessException;

    /**
     * 根据用户名查找用户
     */
    User getAdminByUserName(String username);

    /**
     * 根据用户id查询角色列表
     */
    List<Role> getRole(Long userId);

    /**
     * 登录之后返回token
     * @param code
     * @return
     */
    Result login( String code,LoginRequest loginRequest,HttpServletRequest request);
}
